package com.tutorial.painttest;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class PaintCon extends JFrame{
	public PaintCon(){
		init();
		this.setVisible(true);
	}
	
	public void init(){
		this.setBounds(0, 0, 400, 400);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		TP p = new TP();
		this.getContentPane().add(p);
	}
	
	@Override
	public void paint(Graphics arg0) {
		super.paint(arg0);
	}
	
	public static void main(String[] args) {
		new PaintCon();
	}
}

class TP extends JPanel{
	public TP(){
		this.setPreferredSize(new Dimension(200,200));
	}

	@Override
	protected void paintComponent(Graphics g) {
		g.setColor(Color.blue);
		g.fillRect(0, 0, getWidth(), getHeight());
		g.setColor(Color.red);
		g.fillOval(0, 0, getWidth(), getHeight());
	}
}
